#pragma once
#include "Cloth_Lib.h"
class Doll
{
public:
	int n ;
	Vec3 ball[30];
	float radius[30]; 
	float x0,y0;


	Doll(void);
	~Doll(void);
	void Add(float x,float y,float radi);
	void drawShaded();
	int i;
};
void Doll::drawShaded()
{
	 // to draw the ball we use glutSolidSphere, and need to draw the sphere at the position of the ball
	for(i = 0;i<n;i++)
	{
		glPushMatrix();
		glTranslatef(x0+ball[i].f[0],y0+ball[i].f[1],ball[i].f[2]); // hence the translation of the sphere onto the ball position
		//glTranslatef(1,2,0); // hence the translation of the sphere onto the ball position
		glColor3f(0.4f,0.8f,0.5f);
		glutSolidSphere(radius[i]-0.1,50,50); // draw the ball, but with a slightly lower radius, otherwise we could get ugly visual artifacts of cloth penetrating the ball slightly
		glPopMatrix();
		//cout << ball[i].f[0] <<  " " << ball[i].f[1] <<" " <<ball[i].f[2] << endl;
		//cout << radius[i]-0.1;
	}
	
}
void Doll::Add(float x,float y,float radi)
{
	ball[n].f[0] =x;	
	ball[n].f[1] =y;
	ball[n].f[2] = 0;
	radius[n] = radi;
	n++;
}
Doll::Doll(void)
{
	n=0;
	x0=y0= 0;
	x0 = 5;
	y0= - 2.5;


	Add(0,0,2.1);
	Add(0,2.5,1.5);
	Add(0,-3.0,2.1);
	Add(0,-6,2.1);
	//
	float arm_radius = 0.8;
	float d = 0.7;
	float dy = 0.5;
	float arm_pos = 1.5;
	float arm_pos_y = 0.5;
	Add(arm_pos,arm_pos_y,arm_radius);
	Add(arm_pos+d,arm_pos_y - dy,arm_radius);
	Add(arm_pos+2*d,arm_pos_y - 2*dy,arm_radius);
	Add(arm_pos+3*d,arm_pos_y - 3*dy,arm_radius);
	Add(arm_pos+4*d,arm_pos_y - 4*dy,arm_radius);
	//
	Add(-arm_pos,arm_pos_y ,arm_radius);
	Add(-arm_pos - d,arm_pos_y - 1*dy,arm_radius);
	Add(-arm_pos - 2*d,arm_pos_y - 2*dy,arm_radius);
	Add(-arm_pos - 3*d,arm_pos_y - 3*dy,arm_radius);
	Add(-arm_pos - 4*d,arm_pos_y - 4*dy,arm_radius);
	
	//Add(0,0,2.1);
}

Doll::~Doll(void)
{
}